package dao;

import java.util.List;

import model.Admin;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;

import support.Result;

@Component
public class UserDao extends BaseDao {
	public Result login_check(String username, String password)
	{
		Session s = session();
		Criteria cri = s.createCriteria(Admin.class);
		cri.add(Restrictions.eq("admin_login_name", username));
		cri.add(Restrictions.eq("admin_password", password));
		List<Admin> objs = cri.list();
		if (objs.size() > 0)
			return new Result(true, "", objs.get(0));
		else
			return new Result(false, "", null);
	}
}
